﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL.Route;
using Model.Route;
using System.Data;

namespace BLL.Route
{
    public class TravelRouteBLL
    {
        private readonly TravelRouteDAL dal = new TravelRouteDAL();
        
         
         /// <summary>
        /// 得到一组线路购物的JOSN对象
        /// </summary>
        public string GetAddditionalOrderJoanString(int routeId)
        {
            return dal.GetAddditionalOrderJoanString(routeId);
        }
        
        /// <summary>
        /// 添加线路定点购物
        /// </summary>
        public bool AdditionalOrder(AdditionalOrder model)
        {
           return dal.AdditionalOrder(model);
        }
        
          /// <summary>
        /// 添加线路附加费用
        /// </summary>
        public bool Additionalfee(Additionalfee model)
        {
            return dal.Additionalfee(model);
        }
        
        public bool Delete(string routeID)
        {
            return dal.Delete(routeID);
        }


        public bool DeleteEffTime(string TimeidList)
        {
            return dal.DeleteEffTime(TimeidList);
        }
        /// <summary>
        /// 删除一条产品的子项
        /// </summary>
        /// <param name="routeIdlist"></param>
        /// <returns></returns>
        public bool DeleteDetail(string routeIdlist)
        {
            return dal.DeleteDetail(routeIdlist);
        }

        /// <summary>
        /// 删除线路购物行程表
        /// </summary>
        /// <param name="RouteId"></param>
        /// <returns></returns>
        public bool DelBatchAdditionalOrder(string RouteId)
        {
            return dal.DelBatchAdditionalOrder(RouteId);
        }
        
        
        
        /// <summary>
        /// 删除线路具体日期行程表
        /// </summary>
        /// <param name="RouteId"></param>
        /// <returns></returns>
        public bool DelBatchAdditionalFee(string RouteId)
        {
            return dal.DelBatchAdditionalFee(RouteId);
        }
        
        
        public bool DelBatchDetail(string RouteId)
        {
            return dal.DelBatchDetail(RouteId);
        }
        
        
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string routeIdlist)
        {
            return dal.DeleteList(routeIdlist);
        }

        /// <summary>
        /// 增加产品有效日期
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddEffTime(TravelProductEffTime model)
        {
            return dal.AddTime(model);
        }
        
        /// <summary>
        /// 增加一条子产品项
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        public bool AddDetail(TravelProductDetail mode)
        {
            return dal.AddDetail(mode);
        }

        public int getSql()
        {
            return dal.getSql();
        }
        
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// 
        public bool Add(TravelProduct model)
        {
            return dal.Add(model);
        }

        public int AddByString(TravelProduct model)
        {
            return dal.AddByString(model);    
        }

        /// <summary>
        /// 修改一条子产品项目
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateDetail(TravelProductDetail model)
        {
            return dal.UpdateDetail(model);
        }
        /// <summary>
        /// 修改产品日期
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateTime(TravelProductEffTime model)
        {
            return dal.UpdateEffTime(model);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TravelProduct model)
        {
            return dal.Update(model);
        }
        public TravelProductEffTime GetEffTime(int TimeId)
        {
            return dal.GetEffTime(TimeId);
        }
       
        /// <summary>
        /// 得到产品子项列表
        /// </summary>
        /// <param name="routeId"></param>
        /// <returns></returns> 
        public List<TravelProductDetail> GetDetailModeList(int routeId)
        {
            return dal.GetDetailModeList(routeId);
        }
        
        /// <summary>
        /// 得到一个产品子项
        /// </summary>
        /// <param name="routeId"></param>
        /// <returns></returns>
        public TravelProductDetail GetDetailMode(int routeId)
        {
            return dal.GetDetailMode(routeId);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TravelProduct GetModel(int routeId)
        {

            return dal.GetModel(routeId);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<TravelProduct> DataTableToList(DataTable dt)
        {
            List<TravelProduct> modelList = new List<TravelProduct>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                TravelProduct model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new TravelProduct();

                    if (dt.Rows[n]["trid"] != null && dt.Rows[n]["trid"].ToString() != "")
                    {
                        model.trid = int.Parse(dt.Rows[n]["trid"].ToString());
                    }
                    if (dt.Rows[n]["tguid"] != null && dt.Rows[n]["tguid"].ToString() != "")
                    {
                        model.tguid = dt.Rows[n]["tguid"].ToString();
                    }
                    if (dt.Rows[n]["trname"] != null && dt.Rows[n]["trname"].ToString() != "")
                    {
                        model.trname = dt.Rows[n]["trname"].ToString();
                    }
                    if (dt.Rows[n]["tripline1"] != null && dt.Rows[n]["tripline1"].ToString() != "")
                    {
                        model.tripline1 = dt.Rows[n]["tripline1"].ToString();
                    }
                    if (dt.Rows[n]["tripline2"] != null && dt.Rows[n]["tripline2"].ToString() != "")
                    {
                        model.tripline2 = dt.Rows[n]["tripline2"].ToString();
                    }
                    if (dt.Rows[n]["linetype"] != null && dt.Rows[n]["linetype"].ToString() != "")
                    {
                        model.linetype = dt.Rows[n]["linetype"].ToString();
                    }
                    if (dt.Rows[n]["subhead"] != null && dt.Rows[n]["subhead"].ToString() != "")
                    {
                        model.subhead = dt.Rows[n]["subhead"].ToString();
                    }
                    if (dt.Rows[n]["title1"] != null && dt.Rows[n]["title1"].ToString() != "")
                    {
                        model.title1 = dt.Rows[n]["title1"].ToString();
                    }
                    if (dt.Rows[n]["title2"] != null && dt.Rows[n]["title2"].ToString() != "")
                    {
                        model.title2 = dt.Rows[n]["title2"].ToString();
                    }
                    if (dt.Rows[n]["title3"] != null && dt.Rows[n]["title3"].ToString() != "")
                    {
                        model.title3 = dt.Rows[n]["title3"].ToString();
                    }
                    if (dt.Rows[n]["title4"] != null && dt.Rows[n]["title4"].ToString() != "")
                    {
                        model.title4 = dt.Rows[n]["title4"].ToString();
                    }
                    if (dt.Rows[n]["title5"] != null && dt.Rows[n]["title5"].ToString() != "")
                    {
                        model.title5 = dt.Rows[n]["title5"].ToString();
                    }
                    if (dt.Rows[n]["Vehicle"] != null && dt.Rows[n]["Vehicle"].ToString() != "")
                    {
                        model.Vehicle = dt.Rows[n]["Vehicle"].ToString();
                    }
                    if (dt.Rows[n]["startpoint"] != null && dt.Rows[n]["startpoint"].ToString() != "")
                    {
                        model.startpoint = dt.Rows[n]["startpoint"].ToString();
                    }
                    if (dt.Rows[n]["endpoint"] != null && dt.Rows[n]["endpoint"].ToString() != "")
                    {
                        model.endpoint = dt.Rows[n]["endpoint"].ToString();
                    }
                    if (dt.Rows[n]["trtype"] != null && dt.Rows[n]["trtype"].ToString() != "")
                    {
                        model.trtype = dt.Rows[n]["trtype"].ToString();
                    }
                    if (dt.Rows[n]["SupplierNo"] != null && dt.Rows[n]["SupplierNo"].ToString() != "")
                    {
                        model.SupplierNo = int.Parse(dt.Rows[n]["SupplierNo"].ToString());
                    }
                    if (dt.Rows[n]["destination"] != null && dt.Rows[n]["destination"].ToString() != "")
                    {
                        model.destination = dt.Rows[n]["destination"].ToString();
                    }
                    if (dt.Rows[n]["triptime"] != null && dt.Rows[n]["triptime"].ToString() != "")
                    {
                        model.triptime = dt.Rows[n]["triptime"].ToString();
                    }
                    if (dt.Rows[n]["tripday"] != null && dt.Rows[n]["tripday"].ToString() != "")
                    {
                        model.tripday = int.Parse(dt.Rows[n]["tripday"].ToString());
                    }
                    if (dt.Rows[n]["tripnight"] != null && dt.Rows[n]["tripnight"].ToString() != "")
                    {
                        model.tripnight = int.Parse(dt.Rows[n]["tripnight"].ToString());
                    }
                    if (dt.Rows[n]["tripsummary"] != null && dt.Rows[n]["tripsummary"].ToString() != "")
                    {
                        model.tripsummary = dt.Rows[n]["tripsummary"].ToString();
                    }
                    if (dt.Rows[n]["hotel"] != null && dt.Rows[n]["hotel"].ToString() != "")
                    {
                        model.hotel = dt.Rows[n]["hotel"].ToString();
                    }
                    if (dt.Rows[n]["diet"] != null && dt.Rows[n]["diet"].ToString() != "")
                    {
                        model.diet = dt.Rows[n]["diet"].ToString();
                    }
                    if (dt.Rows[n]["traffic"] != null && dt.Rows[n]["traffic"].ToString() != "")
                    {
                        model.traffic = dt.Rows[n]["traffic"].ToString();
                    }
                    if (dt.Rows[n]["adultprice"] != null && dt.Rows[n]["adultprice"].ToString() != "")
                    {
                        model.adultprice = int.Parse(dt.Rows[n]["adultprice"].ToString());
                    }
                    if (dt.Rows[n]["kidprice"] != null && dt.Rows[n]["kidprice"].ToString() != "")
                    {
                        model.kidprice = int.Parse(dt.Rows[n]["kidprice"].ToString());
                    }
                    if (dt.Rows[n]["traffic"] != null && dt.Rows[n]["traffic"].ToString() != "")
                    {
                        model.traffic = dt.Rows[n]["traffic"].ToString();
                    }
                    if (dt.Rows[n]["signuplimit"] != null && dt.Rows[n]["signuplimit"].ToString() != "")
                    {
                        model.signuplimit = dt.Rows[n]["signuplimit"].ToString();
                    }
                    if (dt.Rows[n]["costprice"] != null && dt.Rows[n]["costprice"].ToString() != "")
                    {
                        model.costprice = int.Parse(dt.Rows[n]["costprice"].ToString());
                    }
                    if (dt.Rows[n]["pic1url"] != null && dt.Rows[n]["pic1url"].ToString() != "")
                    {
                        model.pic1url = dt.Rows[n]["pic1url"].ToString();
                    }
                    if (dt.Rows[n]["pic2url"] != null && dt.Rows[n]["pic2url"].ToString() != "")
                    {
                        model.pic2url = dt.Rows[n]["pic2url"].ToString();
                    }
                    if (dt.Rows[n]["pic3url"] != null && dt.Rows[n]["pic3url"].ToString() != "")
                    {
                        model.pic3url = dt.Rows[n]["pic3url"].ToString();
                    }
                    if (dt.Rows[n]["pic4url"] != null && dt.Rows[n]["pic4url"].ToString() != "")
                    {
                        model.pic4url = dt.Rows[n]["pic4url"].ToString();
                    }
                    if (dt.Rows[n]["pic5url"] != null && dt.Rows[n]["pic5url"].ToString() != "")
                    {
                        model.pic5url = dt.Rows[n]["pic5url"].ToString();
                    }
                    if (dt.Rows[n]["ispass"] != null && dt.Rows[n]["ispass"].ToString() != "")
                    {
                        model.ispass = dt.Rows[n]["ispass"].ToString();
                    }
                    if (dt.Rows[n]["issele"] != null && dt.Rows[n]["issele"].ToString() != "")
                    {
                        model.issele = dt.Rows[n]["issele"].ToString();
                    }
                    if (dt.Rows[n]["contacts"] != null && dt.Rows[n]["contacts"].ToString() != "")
                    {
                        model.contacts = dt.Rows[n]["contacts"].ToString();
                    }
                    if (dt.Rows[n]["phone"] != null && dt.Rows[n]["phone"].ToString() != "")
                    {
                        model.phone = dt.Rows[n]["phone"].ToString();
                    }
                    if (dt.Rows[n]["expirydate"] != null && dt.Rows[n]["expirydate"].ToString() != "")
                    {
                        model.expirydate = int.Parse(dt.Rows[n]["expirydate"].ToString());
                    }
                    if (dt.Rows[n]["channel"] != null && dt.Rows[n]["channel"].ToString() != "")
                    {
                        model.channel = dt.Rows[n]["channel"].ToString();
                    }
                    if (dt.Rows[n]["qq"] != null && dt.Rows[n]["qq"].ToString() != "")
                    {
                        model.qq = dt.Rows[n]["qq"].ToString();
                    }
                    if (dt.Rows[n]["costexplain1"] != null && dt.Rows[n]["costexplain1"].ToString() != "")
                    {
                        model.costexplain1 = dt.Rows[n]["costexplain1"].ToString();
                    }
                    if (dt.Rows[n]["costexplain2"] != null && dt.Rows[n]["costexplain2"].ToString() != "")
                    {
                        model.costexplain2 = dt.Rows[n]["costexplain2"].ToString();
                    }
                    if (dt.Rows[n]["ordernote1"] != null && dt.Rows[n]["ordernote1"].ToString() != "")
                    {
                        model.ordernote1 = dt.Rows[n]["ordernote1"].ToString();
                    }
                    if (dt.Rows[n]["ordernote2"] != null && dt.Rows[n]["ordernote2"].ToString() != "")
                    {
                        model.ordernote2 = dt.Rows[n]["ordernote2"].ToString();
                    }
                    if (dt.Rows[n]["refundexplain"] != null && dt.Rows[n]["refundexplain"].ToString() != "")
                    {
                        model.refundexplain = dt.Rows[n]["refundexplain"].ToString();
                    }
                    if (dt.Rows[n]["note"] != null && dt.Rows[n]["note"].ToString() != "")
                    {
                        model.pic5url = dt.Rows[n]["note"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetDetailRecordCount(string strWhere)
        {
            return dal.GetDetailRecordCount(strWhere);
        }
        
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }


        /// <summary>
        /// 从视图分页获取数据列表
        /// </summary>
        public DataSet GetViewListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetViewListByPage(strWhere, orderby, startIndex, endIndex);
        }
        
        
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strSupplierno,string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetListByPage(strSupplierno,strWhere, orderby, startIndex, endIndex);
        }
        // <summary>
        ///  获取线路购特的项目的记录总数
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public int GetAdditionalOrderCount(string strWhere)
        {
            return dal.GetAdditionalOrderCount(strWhere);
        }
        
        
        
        /// <summary>
        ///  获取线路另付费的项目的记录总数
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>

        public int GetAdditional_Count(string strWhere)
        {
            return dal.GetAdditional_Count(strWhere);
        }
        
        
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetEveryDetailRecordCount(string strWhere)
        {
            return dal.GetEveryDetailRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetDetailListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetDetailListByPage(strWhere, orderby, startIndex, endIndex);
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetEffTimeRecordCount(string strWhere)
        {
            return dal.GetEffTimeRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetEffTimeListByPage(string sTrid,string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetEffTimeListByPage(sTrid,strWhere, orderby, startIndex, endIndex);
        }

        public string GetDetailJoanString(int routeId)
        {
            return dal.GetDetailJoanString(routeId);
        }

        /// <summary>
        /// 得到一组线路另付费用的JOSN对象
        /// </summary>
        public string GetAddditionalFeeJoanString(int routeId)
        {
            return dal.GetAddditionalFeeJoanString(routeId);
        }
        
    }
}
